package agh.tk.markuptranslation;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;


public class MainMediaWiki {
	public static MediaWikiParser createMediaWikiParser(InputStream input) throws IOException {
		ANTLRInputStream antlrInputStream = new ANTLRInputStream(input);
		MediaWikiLexer lexer = new MediaWikiLexer(antlrInputStream);
		CommonTokenStream commonTokenStream = new CommonTokenStream(lexer);
		MediaWikiParser parser = new MediaWikiParser(commonTokenStream);
		return parser;
	}

	/**
	 * @param args
	 */
	public static void main(String args[])
	{
		try 
		{
			MediaWikiParser parser = createMediaWikiParser(new FileInputStream(new File("MediaWikiList.txt")));
			//MediaWikiParser.mediaWikiFile_return result = parser.mediaWikiFile();
			//IComponent component = result.value ;
			IComponent component = parser.start().value;
			System.out.println(component.toMediaWiki());
			System.out.println("======================================");
			System.out.println(component.toHTML());
			//System.out.println(component.toTxt2tags()) ;
			//System.out.println("------------------------------------------------------------------------") ;
			//System.out.println(component.toDokuWiki()) ;
		}
		catch (FileNotFoundException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (org.antlr.runtime.RecognitionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
